package com.xy.consumer.controller;

import com.xy.consumer.server.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dept")
@RefreshScope //实现配置自动更新
public class DeptProxyController {

    @Value("${default.dt}")
    private String dt;

    @Autowired
    DeptClientService deptClientService;


    @RequestMapping("/get/{id}")
    public String getDept(@PathVariable(value = "id") Integer id) {
        String res = deptClientService.getDept(id);
        return res;
    }

    @RequestMapping("/list")
    public List listDept() {
        return deptClientService.getDeptList();
    }

    @RequestMapping("/dt")
    public String dt() {
        String pDt = deptClientService.dt();
        return "cDt:" + dt + ",pDt:" + pDt;
    }


}
